﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Search.SearchContextAttribute
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;

#nullable disable
namespace UnityEngine.Search
{
  /// <summary>
  ///   <para>This attribute can be attached to a component object field in order to have the ObjectField use the advanced Object Picker.</para>
  /// </summary>
  [AttributeUsage(AttributeTargets.Field)]
  public class SearchContextAttribute : PropertyAttribute
  {
    /// <summary>
    ///   <para>Initial search query used to open the Object Picker window.</para>
    /// </summary>
    public string query { get; private set; }

    /// <summary>
    ///   <para>A list of Search Provider IDs that will be used to create the search context.</para>
    /// </summary>
    public string[] providerIds { get; private set; }

    /// <summary>
    ///   <para>Search provider concrete types that will be instantiated and assigned to the Object Picker search context.</para>
    /// </summary>
    public System.Type[] instantiableProviders { get; private set; }

    /// <summary>
    ///   <para>Search view flags used to open the Object Picker in various states.</para>
    /// </summary>
    public SearchViewFlags flags { get; private set; }

    /// <summary>
    ///   <para>Search context constructor used to add some search context to an object field.</para>
    /// </summary>
    /// <param name="query">Initial search query text used to open the Object Picker window.</param>
    /// <param name="flags">Search view flags used to open the Object Picker in various states.</param>
    /// <param name="providerIdsCommaSeparated">A list of Search Provider IDs that will be used to create the search context.</param>
    /// <param name="instantiableProviders">Search provider concrete types that will be instantiated and assigned to the Object Picker search context.</param>
    public SearchContextAttribute(string query)
      : this(query, (string) null, SearchViewFlags.None)
    {
    }

    /// <summary>
    ///   <para>Search context constructor used to add some search context to an object field.</para>
    /// </summary>
    /// <param name="query">Initial search query text used to open the Object Picker window.</param>
    /// <param name="flags">Search view flags used to open the Object Picker in various states.</param>
    /// <param name="providerIdsCommaSeparated">A list of Search Provider IDs that will be used to create the search context.</param>
    /// <param name="instantiableProviders">Search provider concrete types that will be instantiated and assigned to the Object Picker search context.</param>
    public SearchContextAttribute(string query, SearchViewFlags flags)
      : this(query, (string) null, flags)
    {
    }

    /// <summary>
    ///   <para>Search context constructor used to add some search context to an object field.</para>
    /// </summary>
    /// <param name="query">Initial search query text used to open the Object Picker window.</param>
    /// <param name="flags">Search view flags used to open the Object Picker in various states.</param>
    /// <param name="providerIdsCommaSeparated">A list of Search Provider IDs that will be used to create the search context.</param>
    /// <param name="instantiableProviders">Search provider concrete types that will be instantiated and assigned to the Object Picker search context.</param>
    public SearchContextAttribute(string query, string providerIdsCommaSeparated)
      : this(query, providerIdsCommaSeparated, SearchViewFlags.None)
    {
    }

    /// <summary>
    ///   <para>Search context constructor used to add some search context to an object field.</para>
    /// </summary>
    /// <param name="query">Initial search query text used to open the Object Picker window.</param>
    /// <param name="flags">Search view flags used to open the Object Picker in various states.</param>
    /// <param name="providerIdsCommaSeparated">A list of Search Provider IDs that will be used to create the search context.</param>
    /// <param name="instantiableProviders">Search provider concrete types that will be instantiated and assigned to the Object Picker search context.</param>
    public SearchContextAttribute(
      string query,
      string providerIdsCommaSeparated,
      SearchViewFlags flags)
      : this(query, flags, providerIdsCommaSeparated, (System.Type[]) null)
    {
    }

    /// <summary>
    ///   <para>Search context constructor used to add some search context to an object field.</para>
    /// </summary>
    /// <param name="query">Initial search query text used to open the Object Picker window.</param>
    /// <param name="flags">Search view flags used to open the Object Picker in various states.</param>
    /// <param name="providerIdsCommaSeparated">A list of Search Provider IDs that will be used to create the search context.</param>
    /// <param name="instantiableProviders">Search provider concrete types that will be instantiated and assigned to the Object Picker search context.</param>
    public SearchContextAttribute(string query, params System.Type[] instantiableProviders)
      : this(query, SearchViewFlags.None, (string) null, instantiableProviders)
    {
    }

    /// <summary>
    ///   <para>Search context constructor used to add some search context to an object field.</para>
    /// </summary>
    /// <param name="query">Initial search query text used to open the Object Picker window.</param>
    /// <param name="flags">Search view flags used to open the Object Picker in various states.</param>
    /// <param name="providerIdsCommaSeparated">A list of Search Provider IDs that will be used to create the search context.</param>
    /// <param name="instantiableProviders">Search provider concrete types that will be instantiated and assigned to the Object Picker search context.</param>
    public SearchContextAttribute(
      string query,
      SearchViewFlags flags,
      params System.Type[] instantiableProviders)
      : this(query, flags, (string) null, instantiableProviders)
    {
    }

    /// <summary>
    ///   <para>Search context constructor used to add some search context to an object field.</para>
    /// </summary>
    /// <param name="query">Initial search query text used to open the Object Picker window.</param>
    /// <param name="flags">Search view flags used to open the Object Picker in various states.</param>
    /// <param name="providerIdsCommaSeparated">A list of Search Provider IDs that will be used to create the search context.</param>
    /// <param name="instantiableProviders">Search provider concrete types that will be instantiated and assigned to the Object Picker search context.</param>
    public SearchContextAttribute(
      string query,
      SearchViewFlags flags,
      string providerIdsCommaSeparated,
      params System.Type[] instantiableProviders)
    {
      this.query = string.IsNullOrEmpty(query) || query.EndsWith(" ") ? query : query + " ";
      string[] strArray;
      if (providerIdsCommaSeparated == null)
        strArray = (string[]) null;
      else
        strArray = providerIdsCommaSeparated.Split(',', ';');
      if (strArray == null)
        strArray = new string[0];
      this.providerIds = strArray;
      this.instantiableProviders = instantiableProviders ?? new System.Type[0];
      this.flags = flags;
    }
  }
}
